#Variables
APP = des

#Usual compilation flags
CFLAGS = -std=c99 -Wall -Wextra -g -O2
CPPFLAGS = -I -DDEBUG
LDFLAGS = -lm
SRC = ./src

#Special rules and targets
.PHONY: all genkey clean help 

#Rules and targets
all: $(APP)

$(APP): $(SRC)/des.o $(SRC)/main.o
	$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@

main.o: $(SRC)/main.c $(SRC)/des.h
	$(CC) $(CFLAGS) $(CPPFLAGS) -c $<

genkey.o: $(SRC)/genkey.c $(SRC)/des.h
	$(CC) $(CFLAGS) $(CPPFLAGS) -c $<	

des.o: $(SRC)/des.c $(SRC)/des.h
	$(CC) $(CFLAGS) $(CPPFLAGS) -c $<

genkey: $(SRC)/genkey.o $(SRC)/des.o
	$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@

clean:
	@rm -f $(SRC)/*.o $(APP) genkey

help :
	@echo -e "Usage :"
	@echo -e "  make all		build the software"
	@echo -e "  make genkey		build the key generator"
	@echo -e "  make clean		remove all files generated by make"
	@echo -e "  make help		display this help"
